package com.gopay.bis.manager.bank.impl;

import java.util.Date;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.gopay.bis.dao.bankorder.BankAuthOrderDAO;
import com.gopay.bis.manager.bank.BankAuthOrderManager;
import com.gopay.common.domain.bank.BankAuthOrder;
import com.gopay.common.util.DateUtils;

/** 
 * 委托代收认证主订单Manager 实现
 * @ClassName: BankAuthOrderManagerImpl 
 * @author w_jiqing 
 * @date 2017年2月10日 下午1:22:38  
 */ 
@Service("bankAuthOrderManager")
public class BankAuthOrderManagerImpl implements BankAuthOrderManager{
    
    @Resource(name = "bankAuthOrderDAO")
    private BankAuthOrderDAO bankAuthOrderDAO;

    @Override
    public BankAuthOrder addBankAuthOrder(BankAuthOrder authOrder) {
        Date curDate = DateUtils.getSystemDate();
        authOrder.setCreatedTs(curDate);
        authOrder.setLastUpdTs(curDate);
        authOrder= bankAuthOrderDAO.save(authOrder);
        return authOrder;
    }

    @Override
    public int updateBackSuccess(BankAuthOrder authOrder) {
        Date curDate = DateUtils.getSystemDate();
        authOrder.setLastUpdTs(curDate);
        int result = bankAuthOrderDAO.updateBackStatus(authOrder);
        return result;
    }

    @Override
    public int updateBackFail(BankAuthOrder authOrder) {
        Date curDate = DateUtils.getSystemDate();
        authOrder.setLastUpdTs(curDate);
        int result = bankAuthOrderDAO.updateBackStatus(authOrder);
        return result;
    }

    @Override
    public int updateAutoQuerySuccess(BankAuthOrder authOrder) {
        Date curDate = DateUtils.getSystemDate();
        authOrder.setLastUpdTs(curDate);
        int result = bankAuthOrderDAO.updateBackStatus(authOrder);
        return result;
    }

    @Override
    public int updateBackVerifyFail(BankAuthOrder authOrder) {
        Date curDate = DateUtils.getSystemDate();
        authOrder.setLastUpdTs(curDate);
        int result = bankAuthOrderDAO.updateBackStatus(authOrder);
        return result;
    }

    @Override
    public int updateAutoQueryFail(BankAuthOrder authOrder) {
        Date curDate = DateUtils.getSystemDate();
        authOrder.setLastUpdTs(curDate);
        int result = bankAuthOrderDAO.updateBackStatus(authOrder);
        return result;
    }

    @Override
    public int updateAuthBankOrderIdbyOrderId(BankAuthOrder authOrder) {
        Date curDate = DateUtils.getSystemDate();
        authOrder.setLastUpdTs(curDate);
        int result = bankAuthOrderDAO.updateBankOrderIdByOrderId(authOrder);
        return result;
    }

    @Override
    public BankAuthOrder getAuthBankOrderByBankId(String bankOrderId) {
        return bankAuthOrderDAO.findAuthBankOrderByBankId(bankOrderId);
    }

}
